<?php

namespace app\admin\controller;

use app\admin\model\UserList;
use app\admin\service\UserService;
use think\facade\Request;

class User extends Base
{
    protected $middleware = ['AdminCheck', 'AdminPermission'];

    public function index()
    {
        if (Request::isAjax()) {
            return $this->getJson(UserList::getList());
        }
        return $this->fetch();
    }

    public function add()
    {
        if (Request::isAjax()) {
            return $this->getJson(UserService::goAdd());
        }
        return $this->fetch();
    }

    public function edit($id)
    {
        if (Request::isAjax()) {
            return $this->getJson(UserService::goEdit());
        }
        return $this->fetch('', ['data' => UserList::find($id)]);
    }

    public function goStatus()
    {
        return $this->getJson(UserService::goStatus());
    }

    public function goRemove()
    {
        return $this->getJson(UserService::goRemove());
    }
}